﻿using System;
using BO.Infrastructure.StaticData;
using BO.Infrastructure.Utils;
using BO.News;
using ChannelVN.Cached.UrlRewrite;
using GUI.Extensions;
using ChannelVN.Cached.Base;

namespace GUI.Pages.Sport
{
    public partial class Index : PageBase
    {

        protected override string CacheConfigName
        {
            get
            {
                return "Pages-Sport-Index";
            }
        }

        protected override bool IsCachedChanged(long newsId, string zoneId, long tagId)
        {
            return !string.IsNullOrEmpty(zoneId);
        }

        public int ZoneId = 0;

        protected void Page_Load(object sender, EventArgs e)
        {

            var objCat = RequestExtensions.Category;
            if (objCat != null)
            {
                ZoneId = objCat.Id;

                #region Title/MetaData
                var mtaCategory = NewsBO.GetInstance().GetCategoryMetaData(objCat.Id);

                if (mtaCategory != null)
                {
                    PresentationUtils.AddMeta(Page, DefinedConstants.MetaAttributes.Description.Id,
                                              DefinedConstants.MetaAttributes.Description.Name, mtaCategory.Description);
                    PresentationUtils.AddMeta(Page, DefinedConstants.MetaAttributes.Keywords.Id,
                                              DefinedConstants.MetaAttributes.Keywords.Name, mtaCategory.Keywords);
                    PresentationUtils.AddMeta(Page, DefinedConstants.MetaAttributes.NewsKeywords.Id,
                                              DefinedConstants.MetaAttributes.NewsKeywords.Name, mtaCategory.Keywords);
                    Page.Header.Title = string.Format(
                    "{0} | soha.vn",
                    mtaCategory.Title);
                }


                #endregion

                return;
            }

            _301Redirection.RedirectToFileNotFoundPage();
        }


    }
}